import javax.swing.*;
public class MyFrame extends JFrame {
    MyPanel mp = null;

    public static void main(String[] args) {
        MyFrame myFrame = new MyFrame();
    }

    public MyFrame() {
        this.setSize(Constant.WINDOW_WIDTH, Constant.WINDOW_HEIGHT);//窗口大小
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);
        mp = new MyPanel();
        this.addKeyListener(mp);
        this.add(mp);
        new Thread(mp).start();
    }
}